package com.androidbook.triviaquiz;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.LinearLayout;
import android.widget.TextView;

public class QuizSplashActivity extends QuizActivity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);
		TextView splashTop = (TextView) findViewById(R.id.TextViewTopTitle);
		Animation fadeTopAnimation = AnimationUtils.loadAnimation(this,
				R.anim.fade_in);
		splashTop.startAnimation(fadeTopAnimation);
		Animation fadeBottomAnimation = AnimationUtils.loadAnimation(
				this, R.anim.fade_in2);
		TextView splashBottom = (TextView) findViewById(R.id.TextViewBottomTitle);
		fadeBottomAnimation.setAnimationListener(new AnimationListener() {
			public void onAnimationRepeat(Animation animation) {
			}

			public void onAnimationEnd(Animation animation) {
				startActivity(new Intent(QuizSplashActivity.this,
						QuizMenuActivity.class));
				QuizSplashActivity.this.finish();
			}

			public void onAnimationStart(Animation animation) {
			}
		});
		splashBottom.startAnimation(fadeBottomAnimation);

		Animation middleSpin = AnimationUtils.loadAnimation(this,
				R.anim.custom_anim);
		LayoutAnimationController middleSpinController = new LayoutAnimationController(
				middleSpin);
		middleSpinController.setOrder(2);
		LinearLayout middleView = (LinearLayout) findViewById(R.id.linearLayout1);
		middleView.setLayoutAnimation(middleSpinController);
		middleView = (LinearLayout) findViewById(R.id.linearLayout2);
		middleView.setLayoutAnimation(middleSpinController);

	}

	@Override
	protected void onResume() {
		super.onResume();
		// ImageView middleView = (ImageView) findViewById(R.id.imageView1);
		// Animation middleSpin = AnimationUtils.loadAnimation(this,
		// R.anim.custom_anim);
		// middleView.startAnimation(middleSpin);
	}

	@Override
	protected void onPause() {
		super.onPause();
		// ImageView middleView = (ImageView) findViewById(R.id.imageView1);
		// middleView.clearAnimation();
	}
}